//
//  YeeSuggestVC.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/7.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeSuggestVC.h"

@interface YeeSuggestVC ()
{
    UITextPlaceHolderView  *_textView;
    UILabel                *_countlable;
    UIButton               *_sendButton;
}
@end

@implementation YeeSuggestVC

- (void)viewDidLoad
{
    [super viewDidLoad];
}
-(void)addNavbarView
{
    [super addNavbarView];
    self.title=@"意见反馈";
}
-(void)addOwnViews
{
    [super addOwnViews];
    
    _textView=[[UITextPlaceHolderView alloc] initWithFrame:CGRectMake(15, 30, kMainScreenWidth-30, 150)];
    _textView.layer.masksToBounds=YES;
    _textView.layer.cornerRadius=5.0f;
    _textView.placeholder=@"请输入你的意见反馈";
    [self.view addSubview:_textView];
    
    _countlable=[[UILabel alloc] initWithFrame:CGRectMake(kMainScreenWidth-70, CGRectGetMaxY(_textView.frame)-21, 55, 21)];
    _countlable.text=@"6-400字";
    _countlable.textColor=kGrayColor;
    _countlable.font=[UIFont Y_systemFontOfSize:10];
    [self.view addSubview:_countlable];
    
    _sendButton=[UIButton buttonWithType:UIButtonTypeCustom];
    _sendButton.layer.masksToBounds=YES;
    _sendButton.layer.cornerRadius=17.5f;
    _sendButton.enabled=NO;
    _sendButton.titleLabel.font=[UIFont Y_systemFontOfSize:13];
    [_sendButton setFrame:CGRectMake(15, 200, kMainScreenWidth-30, 35)];
    [_sendButton setTitle:@"发送" forState:UIControlStateNormal];
    [_sendButton setBackgroundImage:[UIImage imageWithColor:kGrayColor] forState:UIControlStateDisabled];
    [_sendButton setBackgroundImage:[UIImage imageWithColor:kNavBarThemeColor] forState:UIControlStateNormal];
    [self.view addSubview:_sendButton];

}
-(void)configOwnViews
{
    [super configOwnViews];
    [self.view setBackgroundColor:xBackgroundColor];
}
-(void)bindViewModel
{
    [super bindViewModel];
    [_textView.rac_textSignal subscribeNext:^(NSString * _Nullable x)
     {
         if (x.length>6)
         { _sendButton.enabled=YES;
         }else
         { _sendButton.enabled=NO;
         }
     }];
    [[_sendButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x)
     {
         [self.view endEditing:YES];
         [self executePostNetData];
     }];

}
-(void)executePostNetData
{
    [self.view showNBLoadingMessage:@"努力加载中..."];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.view removeNBLoadingTost];
        [self.view.window showNBSucceedMessage:@"提交成功"];
        [self.navigationController popViewControllerAnimated:YES];
    });
    
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
